class Player {
    constructor(info){
        this.info = info;
        this.uid = info.uid;
        this.prepare = false;
        this.offline = false;
        this.totalscore = 0;
        this.iskan = false;
        this.score = 0;
        this.seat = -1;
        this.cards = [-1, -1, -1];
        this.cardtype = 0;
        this.iswin = false;

        this._isSee = false;     // 未看牌、已看牌
        this._isDiscard = false; // 未弃牌、已弃牌
        this._isWin = false;     // 比牌输、比牌赢
        this._whetherCompare = false; // 是否比过牌
    }
    getUid(){
        return this.uid;
    }
    setSeat(seat){
        this.seat = seat;
    }
    getSeat(){
        return this.seat;
    }
    isPrepare(){
        return this.prepare;
    }
    setPrepare(prepare){
        this.prepare = prepare;
    }
    getConfig(){
        this.info.seat = this.seat;
        this.info.prepare = this.prepare;
        this.info.offline = this.offline;
        this.info.score = this.score;
        this.info.totalscore = this.totalscore;
        return this.info;
    }
    isKan(){
        return this.iskan;
    }
    setKan(iskan){
        this.iskan = iskan;
    }
    getBeiShu(){
        if (this.iskan) {
            return 2;
        }
        return 1;
    }
    setCards(cards){
        this.cards = cards;
        console.log(cards);
    }
    getCards(){
        // return this.cards;
        let card_arr = [];
        for (let i = 0; i < this.cards.length; i++){
            card_arr.push(this.cards[i]);
        }
        return card_arr;
    }
    setCardType(type){
        this.cardtype = type;
    }
    getCardType(){
        return this.cardtype;
    }
    setWin(iswin){
        this.iswin = iswin;
    }
    isWin(){
        return this.iswin;
    }
    canExit(){
        let result = false;
        if (this._isDiscard){
            result = true;
        } else {
            if (this._whetherCompare && !this._isWin){
                result = true;
            }
        }
        return result;
    }
}
module.exports = Player;